<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<h2>javascript 能做什么</h2>
<p id="demo">javascript 能够改变 HTML 内容</p>
<input type="button" onclick='changeTest()' value="点击我">
<hr>

<p>javascript 能够改变图像的src属性</p>
<input type="button" onclik="on()" value="开灯">
<img id="myImage" border="0" src="../imgs/off.gif" style="text-aligin:center;">
<input type="button" onclick="off()" value="关灯">
<hr>

<p>javascript 能够进行表单验证</p>
用户名：<input id="username" onblur="check()" placeholder="请设置用户名(6~12)">
<span id="msg" style="color:red"></span>
<hr>

<script>
    function changeText(){
        document.getElementById("demo").innerHTML="hello javascript!"
    }
    function check(){
        var username =document.getElementById('username').vaule;
        var reg=/^\w{6,12}$/;
        var msg =document.getElementById('msg');
        if(reg.test(username)){
            msg.innerHTML="<img src=',,/img/gou.png' width='25' height='15'/>";
        }else{
            msg.innerHTML="用户名格式有误!";
        }
    }
</script>
</body>
</html>